package cn.usbtg.poi.ext.download.celltheme;

import cn.usbtg.poi.ext.download.style.POIStyleUtil;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Workbook;

/**
 * 单元格样式：主题1
 */
public class POICellThemeSolidBorder implements POICellTheme {

    @Override
    public CellStyle theme(Workbook workbook) {
        // 创建单元格样式
        CellStyle cellStyle = workbook.createCellStyle();

        cellStyle.setWrapText(true); //自动换行
        cellStyle.setAlignment(CellStyle.ALIGN_CENTER);//居中
        cellStyle.setVerticalAlignment(CellStyle.VERTICAL_CENTER);//垂直居中

        //边框
        cellStyle.setBottomBorderColor(IndexedColors.BLACK.index);
        cellStyle.setBorderBottom(CellStyle.BORDER_THIN);
        cellStyle.setBorderLeft(CellStyle.BORDER_THIN);
        cellStyle.setBorderRight(CellStyle.BORDER_THIN);
        cellStyle.setBorderTop(CellStyle.BORDER_THIN);

        // 字体
        cellStyle.setFont(POIStyleUtil.createFontDefault(workbook));

        return cellStyle;
    }
}